<script>
	import {
		supplyMsg
	} from './network/main.js';
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
			var token = uni.getStorageSync('token');
			uni.setStorageSync('clear', false)
			if (token) {
				// #ifdef  APP-PLUS
				let timer = setInterval(() => {
					if (uni.getStorageSync('clear')) {
						clearInterval(timer)
					}
					supplyMsg({}).then(res => {
						let msgnum = uni.getStorageSync('msgnum');
						if (msgnum < res.data.data.length) {
							uni.setStorageSync('msgnum', res.data.data.length + ' ');
							uni.showToast({
								title: '您有一条新的消息~',
								icon: 'none',
								position: 'top'
							})
						}
					})
				}, 30000)
				// #endif
			}
		},
		onHide: function() {
			uni.setStorageSync('clear', true)
			console.log('App Hide', '断开连接')
		},
	}
</script>

<style>
	/*每个页面公共css */
	@import url("./static/css/iconfont.css");

	.uni-page-head__title {
		font-size: 18px !important;
	}

	/* 页面公共样式 */
	.content {
		min-height: 100vh;
		background-color: #f7f7f7;
		border-top: 2rpx solid #f7f7f7;
	}

	.placeholder-style {
		font-size: 28rpx;
		color: #999;
	}

	.input-style {
		font-size: 24rpx;
		color: #999;
	}

	.require {
		color: #dd524d;
	}

	.status {
		color: #ff6700 !important;
	}
</style>